package dao

import (
	"ai/internal/db/models"

	"gorm.io/gorm"
)

type UserDAO struct {
	db *gorm.DB
}

func NewUserDAO(db *gorm.DB) *UserDAO {
	return &UserDAO{db: db}
}

func (dao *UserDAO) CreateUser(user *models.User) error {
	return dao.db.Create(user).Error
}

func (dao *UserDAO) GetUserByUsername(username string) (*models.User, error) {
	var user models.User
	err := dao.db.Where("username = ?", username).First(&user).Error
	return &user, err
}
